﻿@{
    ViewBag.Title = "优惠券";
}

    <div class="container">
        <div class="coupon-list">
            <div class="coupon-hd"><span class="only-child">优惠券领取列表</span></div>
            <div class="coupon-bd">
                @{var couponlist = (IEnumerable<Himall.Model.UserCouponInfo>)ViewBag.CouponList;}
                @foreach (var coupon in couponlist)
                {
                    if (coupon.VShop != null)
                    {
                        <ul style="display:block;">
                            <li>
                                <div class="cou-card">
                                    <div><a><img src="@coupon.VShop.Logo" /></a></div>
                                    <p>￥@coupon.Price.ToString()</p>
                                </div>
                                <div class="cou-text clearfix">
									<div class="cou-price">
										<p>满 @coupon.OrderAmount.ToString() 元使用</p>
										<h6>有效期至@(coupon.EndTime.ToString("yyyy-MM-dd"))</h6>
									</div>
									<a name="acceptCoupon" vshopid="@coupon.VShop.Id" cpid="@coupon.CouponId">立即领取<i class="glyphicon glyphicon-menu-right cirle-right"></i></a>
                                </div>
                            </li>
                        </ul>
                    }
                    else
                    {

                        <h5 style="text-align:center; padding:20px 0;"><i class="glyphicon glyphicon-info-sign"></i> 该店铺未开通微店，请到PC端去领取</h5>
                    }
                }
                
            </div>
        </div>

        @{Html.RenderPartial("~/Areas/Mobile/Templates/APP/Views/Shared/_4ButtonsFoot_fav.cshtml");}
    </div>
    <script>
        $(function () {
            $('a[name="acceptCoupon"]').click(function () {
                var $thisCoupon = $(this);
                var cpid = $thisCoupon.attr('cpid') || 0;
                var vshopid = $thisCoupon.attr('vshopid') || 0;
                if (parseInt(cpid) > 0) {
                    $.post('AcceptCoupon', { vshopid: vshopid, couponid: parseInt(cpid) }, function (result) {
                        $.dialog.tips(result.msg, function () { });
                        return;
                    });
                }
            });
        });
    </script>
